package com.shuai.controller;

import com.shuai.model.vo.ProjectVO;
import com.shuai.model.vo.UserVO;
import com.shuai.service.ProjectService;
import com.shuai.utils.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController

@RequestMapping("/project")
@Tag(name = "项目管理")
public class ProjectController {

    @Resource
    private ProjectService projectService;

    @Operation(summary = "首页数据展示")
    @PostMapping(value = "/indexData")
    public R indexData(@RequestBody UserVO vo) {
        return this.projectService.indexData(vo);
    }


    /**
     * projectName N
     * pageIndex Y
     * pageSize Y
     * userId  Y
     *
     * @param params
     * @return
     */
    @PostMapping(value = {"/projectList", "/searchProject"})
    @Operation(summary = "项目列表分页查询")
    public R projectList(@RequestBody Map<String, Object> params) {
        return this.projectService.projectList(params);
    }

    /**
     * managerId Y
     * projectName Y
     * timelimit Y
     * startTime Y
     * entTime Y
     *
     * @param vo
     * @return
     */
    @PostMapping(value = "/addProject")
    @Operation(summary = "添加项目")
    public R addProject(@RequestBody ProjectVO vo) {
        return this.projectService.addProject(vo);
    }


    /**
     * pageIndex
     * pageSize
     * projectId
     *
     * @param params
     * @return
     */
    @PostMapping(value = "/projectInfo")
    @Operation(summary = "查看项目详情")
    public R projectInfo(@RequestBody Map<String, Object> params) {
        return this.projectService.projectInfo(params);
    }

    @PostMapping(value = "/addProjectUserGroup")
    @Operation(summary = "添加项目用户组")
    public R addProjectUserGroup(@RequestBody Map<String, Object> params) {
        return this.projectService.addProjectUserGroup(params);
    }

    @PostMapping(value = "/selectUserOfProject")
    @Operation(summary = "查询项目组成员")
    public R selectUserOfProject(@RequestBody ProjectVO vo) {
        return this.projectService.selectUserOfProject(vo);
    }

    /**
     * 修改项目信息
     * 当前负责人可以修改项目信息
     * 项目负责人的修改只有超级管理员可以修改
     * projectName  N
     * timeLimit   N
     * startTime   N
     * entTime    N
     * managerId   N
     * <p>
     * projectId Y
     *
     * @param
     */
    @PostMapping(value = "/updateProject")
    @Operation(summary = "修改项目")
    public R updateProject(@RequestBody ProjectVO vo) {
        return this.projectService.updateProject(vo);
    }

    @PostMapping(value = "/delProject")
    @Operation(summary = "删除项目")
    public R delProject(@RequestBody ProjectVO vo) {
        return this.projectService.delProject(vo);
    }
}